import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io' as io;

import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:super_tool_server/business/config_manager.dart';
import 'package:super_tool_server/business/log_manager.dart';
import 'package:super_tool_server/common/utils/log.dart';
import 'package:super_tool_server/model/config_info.dart';

class DragUtil {
  static DragUtil? _instance;

  DragUtil._() {}

  static DragUtil getInstance() {
    if (_instance == null) {
      _instance = DragUtil._();
    }
    return _instance!;
  }

  void addLog(String log, {Color color = const Color(0xAFFFFFFF)}) {
    LogManager.getInstance().addLog(log, color: color);
    superLog.info("addLog:  $log");
  }

  void handleDrag(List<String> fileResults) {
    ConfigInfo configInfo = ConfigManager.getInstance().getConfigInfo();
    bool validFile = false;
    for (int i = 0; i < fileResults.length; i++) {
      io.File file = io.File(fileResults[i]);
      io.FileSystemEntity.type(fileResults[i]).then((type) async {
        superLog.info("${file.path}, $type");
      });
    }
  }
}
